import ddt
import unittest

def get_student_info(student_id):
    students = {
        1001: {"name": "方鸿新", "age": 21, "sex": "男"},
        1002: {"name": "苏文芷", "age": 21, "sex": "女"},
        1003: {"name": "唐晓芙", "age": 17, "sex": "女"},
        1004: {"name": "赵辛媚", "age": 16, "sex": "女"}
    }
    return students.get(student_id, "The student ID does not exist.")

@ddt.ddt
class TestGetStudentInfo(unittest.TestCase):
    @ddt.file_data('student_info_test.yaml')
    def test_get_student_info(self, id, expect):
        print("\n" + str(id) + ">>>>>>>>>" + str(expect))
        self.assertEqual(expect, get_student_info(id), "断言失败")


if __name__ == '__main__':
    loader = unittest.TestLoader()
    suit = loader.loadTestsFromTestCase(TestGetStudentInfo)
    runner = unittest.TextTestRunner(verbosity=2)
    runner.run(suit)